import request from "@/utils/request";
import type { ApiConfig, ApiQuery, ApiResponse } from "@/types/api";

export const getApiList = (params: ApiQuery) => {
  return request.get<ApiResponse>("/api/apis", { params });
};

export const createApi = (data: Omit<ApiConfig, "id">) => {
  return request.post<ApiConfig>("/api/apis", data);
};

export const updateApi = (id: number, data: Partial<ApiConfig>) => {
  return request.put<ApiConfig>(`/api/apis/${id}`, data);
};

export const deleteApi = (id: number) => {
  return request.delete(`/api/apis/${id}`);
};

export const testApi = (id: number) => {
  return request.post<{ success: boolean; message: string; data?: any }>(
    `/api/apis/${id}/test`
  );
};
